package com.googlecode.smartbinding.framework.core;

import com.googlecode.smartbinding.framework.converter.Converter;
import com.googlecode.smartbinding.framework.validator.Validator;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Define a binding between a source and a target property.
 *
 * @author Iulian Dumitru
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Binding {

    /**
     * Source property name.
     *
     * @return - the target's property name
     */
    String property();

    /**
     * Target property.
     *
     * @return
     */
    String targetProperty() default "";

    /**
     * Events when databinding occurs.<br/>
     *
     * @return
     */
    EventType[] events() default {EventType.MODIFY};

    /**
     * Delay for observing the events (ms).
     *
     * @return
     */
    int delay() default 0;

    /**
     * Chained validators from source to target
     *
     * @return
     */
    Validator[] sourceToTargetValidators() default {};

    /**
     * Chained validators from target to source.
     *
     * @return
     */
    Validator[] targetToSourceValidators() default {};

    /**
     * Add converter for databinding.
     *
     * @return
     */
    Converter[] converter() default {};

    /**
     * Binding strategy.
     *
     * @return binding strategy to use
     */
    Class<? extends BindingStrategy> bindingStrategy() default DefaultBindingStrategy.class;

}
